#ifndef _DS_DSTRING_H
#define _DS_DSTRING_H

#include "../ds_types.h"
#include <stdlib.h>
#include <stdio.h>

extern Status dstrassign(dstring *s, char *chars);

static inline size_t dstrlen(dstring s)
{
	return s.length;
}

/* if s == t, return 0, if s > t , return >0 */
extern int dstrcmp(dstring s, dstring t);

static inline Status dstrclear(dstring *s)
{
	if(s->ch) free(s->ch);
	s->ch = NULL;
	s->length = 0;
	return SUCCESS;
}

/* concatenate s1, s2 to des */
extern Status dstrcat(dstring *des, dstring s1,dstring s2);

extern Status subdstr(dstring *sub, dstring s, size_t pos, size_t len);

static inline void dstrshow(dstring s)
{
	int i;
	for(i = 0; i < s.length; i++)
		printf("%c", s.ch[i]);
}

/* if not find return -1, if the number pos is error return -2 */
extern int dstrpos(dstring s, dstring p, int pos);

extern int dstrpos_v1(dstring s, dstring p, int pos);
#endif
